﻿using System;
using System.Collections.Generic;
using System.Linq;
using MathNet.Spatial.Euclidean;

namespace FDEE.Model
{
    class CPE12 : CPEBase
    {
        Dictionary<double, List<int>> dic = new Dictionary<double, List<int>>();
        Dictionary<double, List<int>> addDic = new Dictionary<double, List<int>>();
        bool isAdd = false;
        int mainDBdia;
        Dictionary<string, int[]> dicRInfo = new Dictionary<string, int[]>();
        List<int> three_a = new List<int>() { 320,326,341,363,390,424,464,511,563,622};
        List<int> three_b = new List<int>() {172,177,189,206,228,255,285,326,370,421 };
        eDB rebarDB = eDB.DB28;//5号加强筋
        /// <summary>
        /// 
        /// </summary>
        /// <param name="typeName"></param>
        /// <param name="pierNumber"></param>
        /// <param name="ct"></param>
        /// <param name="st"></param>
        /// <param name="ww">宽</param>
        /// <param name="ll">长</param>
        /// <param name="hh"></param>
        /// <param name="up"></param>
        /// <param name="low"></param>
        /// <param name="mainDB"></param>
        /// <param name="topLength">顶部宽度</param>  
        /// <param name="outr"></param>
        /// <param name="innerr"></param>
        /// <param name="sider">侧边半径</param>
        /// <param name="wwside">宽对应变化长度（宽两端varies）</param>
        /// <param name="llside">长对应变化长度（长两端varies）</param>
        internal CPE12(string typeName, string pierNumber, eColumnType ct, eSubType st,
            int ww, int ll, int hh,  double up, double low,
            eDB mainDB,double topLength,double outr, double innerr, double sider,
            double wwside, double llside)
            : base(typeName, pierNumber, ct, st, ww, ll, hh, up, low, outr,innerr,sider,
                  mainDB,wwside,llside, topLength)
        {
            mainDBdia = (int)mainDB;
        }

        /// <summary>
        /// 起步截面布筋均分
        /// </summary>
        public override void SetRebarDistribute()
        {
            dicRInfo = new Dictionary<string, int[]>();
            double d1, d2;
            double d1r, d2r;
            switch (SubType)
            {
                case eSubType.A:
                    rebarDB = eDB.DB28;
                    d1 = (Length - 2 * llSide - mainDBdia) / 4;
                    d2 = (Width - 2 * wwSide - mainDBdia) / 5;
                    rebarDB = eDB.DB28;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 5);
                    if (PierHeight > 1200)
                    {
                        three_a = new List<int>() { 202, 209, 222, 239, 261, 288, 320, 358, 400, 447 };

                        dicRInfo.Add("4.1.a", new int[] { 4811, 3239, 116, 2 });
                        dicRInfo.Add("4.1.b", new int[] { 4811, 3241, 116, 4 });
                        dicRInfo.Add("4.1.c", new int[] { 4811, 3246, 116, 4 });
                        dicRInfo.Add("4.2.a", new int[] { 5824, 3152, 248, 4 });
                        dicRInfo.Add("4.2.b", new int[] { 8011, 3075, 359, 4 });
                        dicRInfo.Add("4.2.c", new int[] { 13690, 3025, 463, 4 });
                        dicRInfo.Add("5.1", new int[] { 5258, 3193, 185, 4 });
                        dicRInfo.Add("5.2", new int[] { 7536, 3086, 297, 4 });
                        dicRInfo.Add("5.3", new int[] { 12229, 3031, 404, 4 });
                        dicRInfo.Add("5.4", new int[] { 36496, 3003, 512, 4 });
                        dicRInfo.Add("5.5", new int[] { 0, 3000, 570, 2 });
               
                    }
                    else
                    {
                        three_a = new List<int>() { 222, 249, 288, 320, 358, 400, 447 };

                        dicRInfo.Add("4.1.a", new int[] { 4811, 2689, 116, 2 });
                        dicRInfo.Add("4.1.b", new int[] { 4811, 2691, 116, 2 });
                        dicRInfo.Add("4.1.c", new int[] { 4811, 2696, 116, 2 });
                        dicRInfo.Add("4.1.d", new int[] { 4811, 2691, 1200, 2 });
                        dicRInfo.Add("4.1.e", new int[] { 4811, 2696, 1200, 2 });
                        dicRInfo.Add("4.2.a", new int[] { 5824, 2602, 248, 2 });
                        dicRInfo.Add("4.2.b", new int[] { 8011, 2526, 359, 2 });
                        dicRInfo.Add("4.2.c", new int[] { 13690, 2475, 463, 2 });
                        dicRInfo.Add("5.1", new int[] { 5258, 2643, 185, 2 });
                        dicRInfo.Add("5.2", new int[] { 7536, 2536, 297, 2 });
                        dicRInfo.Add("5.3", new int[] { 12229, 2482, 404, 2 });
                        dicRInfo.Add("5.4", new int[] { 36496, 2454, 512, 2 });
                        dicRInfo.Add("5.5", new int[] { 0, 2451, 570, 2 });
                        dicRInfo.Add("6.1.a", new int[] { 5824, 2602, 1200, 2 });
                        dicRInfo.Add("6.1.b", new int[] { 8011, 2526, 1200, 2 });
                        dicRInfo.Add("6.1.c", new int[] { 13690, 2475, 1200, 2 });
                        //dicRInfo.Add("6.2.a", new int[] { 5824, 2591, 1200, 2 });
                        //dicRInfo.Add("6.2.b", new int[] { 8011, 2515, 1200, 2 });
                        //dicRInfo.Add("6.2.c", new int[] { 13690, 2464, 1200, 2 });
                        dicRInfo.Add("7.1", new int[] { 5258, 2643, 1200, 2 });
                        dicRInfo.Add("7.2", new int[] { 7536, 2536, 1200, 2 });
                        dicRInfo.Add("7.3", new int[] { 12229, 2482, 1200, 2 });
                        dicRInfo.Add("7.4", new int[] { 36496, 2454, 120, 2 });
                        dicRInfo.Add("7.5", new int[] { 0, 2451, 1200, 2 });
                       
                    }
                    break;
                case eSubType.B:
                    rebarDB = eDB.DB28;
                    d1 = (Length - 2 * llSide - mainDBdia) / 4;
                    d2 = (Width - 2 * wwSide - mainDBdia) / 5;
                    rebarDB = eDB.DB28;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 5);
                    three_a = new List<int>() { 130, 145, 170, 204, 249, 303, 368, 443, 527, 622 };
                    three_b = new List<int>() { 221, 226, 235, 248, 265, 287, 313, 344, 381, 425 };
                    dicRInfo.Add("4.1.a", new int[] { 4811, 3239, 116, 2 });
                    dicRInfo.Add("4.1.b", new int[] { 4811, 3241, 116, 4 });
                    dicRInfo.Add("4.1.c", new int[] { 4811, 3246, 116, 4 });
                    dicRInfo.Add("4.2.a", new int[] { 5672, 3161, 251, 4 });
                    dicRInfo.Add("4.2.b", new int[] { 10521, 3042, 409, 4 });
                    dicRInfo.Add("4.2.c", new int[] { 21408, 3010, 516, 4 });
                    dicRInfo.Add("4.3.a", new int[] { 5195, 3198, 186, 4 });
                    dicRInfo.Add("5.1", new int[] { 7134, 3196, 301, 4 });
                    dicRInfo.Add("5.2", new int[] { 7418, 3089, 365, 4 });
                    dicRInfo.Add("5.3", new int[] { 11229, 3037, 470, 4 });
                    dicRInfo.Add("5.4", new int[] { 314620, 3000, 570, 4 });
                    break;
                case eSubType.C:
                    rebarDB = eDB.DB28;
                    MainRebarDB = eDB.DB32;
                    mainDBdia = (int)MainRebarDB;
                    d1 = (Length - 2 * llSide - mainDBdia ) / 4;
                    d2 = (Width - 2 * wwSide - mainDBdia ) / 6;
                    rebarDB = eDB.DB28;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 6);
                    three_a = new List<int>() { 320, 326, 341, 363, 390, 424, 464, 511, 563, 622 };
                    three_b = new List<int>() { 172, 177, 189, 206, 228, 255, 285, 326, 370, 421 };
                    dicRInfo.Add("4.1.a", new int[] { 4811, 3239, 113, 2 });
                    dicRInfo.Add("4.1.b", new int[] { 4811, 3241, 113, 4 });
                    dicRInfo.Add("4.1.c", new int[] { 4811, 3246, 113, 4 });
                    dicRInfo.Add("4.2.a", new int[] { 5671, 3162, 248, 4 });
                    dicRInfo.Add("4.2.b", new int[] { 11236, 3037, 404, 4 });
                    dicRInfo.Add("4.2.c", new int[] { 29205, 3005, 511, 4 });
                    dicRInfo.Add("4.2.d", new int[] { 45803, 3002, 569, 2 });
                    dicRInfo.Add("4.3.a", new int[] { 5193, 3241, 183, 4 });
                    dicRInfo.Add("5.1", new int[] { 7130, 3097, 298, 4 });
                    dicRInfo.Add("5.2", new int[] { 7745, 3081, 359, 4 });
                    dicRInfo.Add("5.3", new int[] { 12989, 3028, 462, 4 });
                    dicRInfo.Add("5.4", new int[] { 45803, 3002, 569, 2 });
                    break;
                case eSubType.D:
                    rebarDB = eDB.DB32;
                    MainRebarDB = eDB.DB32;
                    MainRebarDB = eDB.DB32;
                    mainDBdia = (int)MainRebarDB;
                    d1 = (Length - 2 * llSide - mainDBdia ) / 4;
                    d2 = (Width - 2 * wwSide - mainDBdia ) / 7;
            
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 7);
                    three_a = new List<int>() { 157, 174, 201, 239, 288, 349, 420, 502, 596, 701 };
                    three_b = new List<int>() { 155, 164, 179, 200, 228, 262, 304, 353, 411, 478 };
                    dicRInfo.Add("4.1.a", new int[] { 4811, 3239, 195, 2 });
                    dicRInfo.Add("4.1.b", new int[] { 4811, 3241, 195, 4 });
                    dicRInfo.Add("4.1.c", new int[] { 4811, 3246, 195, 4 });
                    dicRInfo.Add("4.2.a", new int[] { 5986, 3142, 317, 4 });
                    dicRInfo.Add("4.2.b", new int[] { 6751, 3109, 374, 4 });
                    dicRInfo.Add("4.2.c", new int[] { 12115, 3032, 467, 4 });
                    dicRInfo.Add("4.2.d", new int[] { 45803, 3002, 569, 4 });
                    dicRInfo.Add("4.3.a", new int[] { 5313, 3188, 259, 4 });
                    dicRInfo.Add("5.1", new int[] { 7797, 3097, 428, 4 });
                    dicRInfo.Add("5.2", new int[] { 16537, 3017, 520, 4 });
                  
                    break;
                case eSubType.E:
                    rebarDB = eDB.DB32;
                    MainRebarDB = eDB.DB32;
                    MainRebarDB = eDB.DB32;
                    d1 = (Length - 2 * llSide - mainDBdia) / 5;
                    d2 = (Width - 2 * wwSide - mainDBdia) / 12;
                    //rebarDB = eDB.DB32;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 5);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2,12);
                    three_a = new List<int>() { 176, 184, 198, 217, 242, 273, 309, 350, 397, 450 };
                    //three_b = new List<int>() { 172, 177, 189, 206, 228, 255, 285, 326, 370, 421 };
                    dicRInfo.Add("4.1.a", new int[] { 4811, 3239, 195, 4});
                    dicRInfo.Add("4.1.b", new int[] { 4811, 3242, 116, 4 });
                    dicRInfo.Add("4.1.c", new int[] { 4811, 3246, 116, 4 });
                    dicRInfo.Add("4.2.a", new int[] { 5813, 3152, 248, 4 });
                    dicRInfo.Add("4.2.b", new int[] { 6823, 3106, 304, 4 });
                    dicRInfo.Add("4.2.c", new int[] { 8372, 3068, 357, 4 });
                    dicRInfo.Add("4.2.d", new int[] { 11001, 3039, 408, 4 });
                    dicRInfo.Add("4.2.e", new int[] { 16327, 3017, 459, 4 });
                    dicRInfo.Add("4.2.f", new int[] { 32446, 3004, 513, 4 });
                    dicRInfo.Add("4.2.g", new int[] { 0, 3000, 570, 2 });
                    dicRInfo.Add("4.3.a", new int[] { 5248, 3195, 185, 4 });
                    break;
                case eSubType.F:
                    rebarDB = eDB.DB32;
                    MainRebarDB = eDB.DB32;
                    MainRebarDB = eDB.DB32;
                    d1 = (Length - 2 * llSide - mainDBdia) / 5;
                    d2 = (Width - 2 * wwSide - mainDBdia) / 14;
                    //rebarDB = eDB.DB32;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 5);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 14);
                    three_a = new List<int>() { 183, 190, 203, 220, 242, 269, 301, 337, 379, 426 };
                    //three_b = new List<int>() { 172, 177, 189, 206, 228, 255, 285, 326, 370, 421 };
                    dicRInfo.Add("4.1.a", new int[] { 4811, 3239, 116, 4 });
                    dicRInfo.Add("4.1.b", new int[] { 4811, 3242, 116, 4 });
                    dicRInfo.Add("4.1.c", new int[] { 4811, 3246, 116, 4 });
                    dicRInfo.Add("4.2.a", new int[] { 5673, 3161, 251, 4 });
                    dicRInfo.Add("4.2.b", new int[] { 6486, 3119, 309, 4 });
                    dicRInfo.Add("4.2.c", new int[] { 7648, 3083, 363, 4 });
                    dicRInfo.Add("4.2.d", new int[] { 9422, 3953, 415, 4 });
                    dicRInfo.Add("4.2.e", new int[] { 12420, 3030, 466, 4 });
                    dicRInfo.Add("4.2.f", new int[] { 18476, 3013, 518, 4 });
                    dicRInfo.Add("4.2.g", new int[] { 36768, 3003, 572, 4 });
                    dicRInfo.Add("4.2.h", new int[] { 0, 3000,600, 2 });
                    dicRInfo.Add("4.3.a", new int[] { 5194, 3198, 415, 4 });

                    break;

            }
        }
        public void SetRebarDistributeNew(double Length, double Width)
        {
            double d1, d2;
            double d1r, d2r;
            switch (SubType)
            {
                case eSubType.A:
                    rebarDB = eDB.DB28;
                    d1 = (Length - mainDBdia) / 4;
                    d2 = (Width - mainDBdia) / 5;
                    rebarDB = eDB.DB28;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 5);

                    break;
                case eSubType.B:
                    rebarDB = eDB.DB28;
                    d1 = (Length - mainDBdia) / 4;
                    d2 = (Width - mainDBdia) / 5;
                    rebarDB = eDB.DB28;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 5);

                    break;
                case eSubType.C:
                    rebarDB = eDB.DB28;
                    d1 = (Length  - mainDBdia) / 4;
                    d2 = (Width  - mainDBdia) / 6;
                    rebarDB = eDB.DB28;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 6);
                   
                    break;
                case eSubType.D:
                    d1 = (Length  - mainDBdia) / 4;
                    d2 = (Width  - mainDBdia) / 7;
                    rebarDB = eDB.DB32;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 7);
                   
                    break;
                case eSubType.E:
                    rebarDB = eDB.DB28;
                    d1 = (Length  - mainDBdia) / 5;
                    d2 = (Width  - mainDBdia) / 12;
                    rebarDB = eDB.DB32;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 5);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 12);
                   
                    break;
                case eSubType.F:
                    rebarDB = eDB.DB28;
                    d1 = (Length  - mainDBdia) / 5;
                    d2 = (Width  - mainDBdia) / 14;
                    //I,II截面参数
                    MainLBarDistribute = new RebarTendonDistribute(mainDBdia, d1, 5);
                    MainWBarDistribute = new RebarTendonDistribute(mainDBdia, d2, 14);
                    
                    break;

            }
        }

        public void SetRebarDistributeIIINew(double L, double W)
        {
            double d1, d2;
            switch (SubType)
            {
                case eSubType.A:

                    d1 = (L - mainDBdia) / 4;
                    d2 = (W - mainDBdia) / 12;
                    //III截面参数
                    MainLBarDistribute = new RebarTendonDistribute(12, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(12, d2, 12);

                    break;
                case eSubType.B:

                    d1 = (L - mainDBdia) / 4;
                    d2 = (W - mainDBdia) / 13;
                    //III截面参数
                    MainLBarDistribute = new RebarTendonDistribute(12, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(12, d2, 13);

                    break;
                case eSubType.C:

                    d1 = (L - mainDBdia ) / 4;
                    d2 = (W - mainDBdia) / 13;
                    //III截面参数
                    MainLBarDistribute = new RebarTendonDistribute(12, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(12, d2, 12);

                    break;
                case eSubType.D:

                    d1 = (L  - mainDBdia ) / 4;
                    d2 = (W  - mainDBdia ) / 11;

                    //III截面参数
                    MainLBarDistribute = new RebarTendonDistribute(12, d1, 4);
                    MainWBarDistribute = new RebarTendonDistribute(12, d2, 12);

                    break;
                case eSubType.E:

                    d1 = (L - mainDBdia ) / 5;
                    d2 = (W  - mainDBdia ) / 12;

                    //III截面参数
                    MainLBarDistribute = new RebarTendonDistribute(12, d1, 5);
                    MainWBarDistribute = new RebarTendonDistribute(12, d2, 12);

                    break;
                case eSubType.F:

                    d1 = (L  - mainDBdia ) / 5;
                    d2 = (W  - mainDBdia ) / 14;

                    //III截面参数
                    MainLBarDistribute = new RebarTendonDistribute(12, d1, 5);
                    MainWBarDistribute = new RebarTendonDistribute(12, d2, 14);

                    break;
            }
        }

        public override void SetRebarList()
        {
            if (PierHeight < 3000)
            {
                if (PierHeight > 1200)
                    SetRebarList258();
                else
                    SetRebarList110();
            }
            else
            {
                #region 0-箍筋
                int npts = GetStirrupNum() + 3;

                int a = 0, b = 0, c = 0;
                //1号筋
                CalPara(Width, Length, wwSide, llSide, ref a, ref b, ref c);
                RebarList.Add(new MRORebarRecord(1, 0, "", eDB.DB12, npts, eShapeType.MRO, a, b, c));
                //RebarList.Add(new MRORebarRecord(1, 0, "a", eDB.DB16, 3, eShapeType.MRO, a, b, c));
                //箍筋变化筋数量
                int num = (int)LenUpper / 300;
                double r1 = 0;
                double r0 = 0;
                double r2 = 0;
                double x = 0;
                double y = 0;
                double xI = 0;
                double yI = 0;
                double xS = 0;
                double yS = 0;
                CalArcCenter(1750 - Width * 0.5, 0, 0, 3000, OuterRadius, 0, ref r1, ref x, ref y);
                CalArcCenter(1750 - Width * 0.5 + wwSide, 0, 0, 3000, InnerRadius, 0, ref r0, ref xI, ref yI);
                CalArcCenter(450 - llSide, 0, 0, 3000, SideRadius, 0, ref r2, ref xS, ref yS);
                for (int m = 1; m <= num; m++)
                {

                    double h0 = 300 * m * 0.001;
                    if (m >= 8)
                        h0 = 300 * m * 0.001 - 3 * 0.001;
                    //double w = 2* GetXByH(h0)*1000;
                    double w = 2 * GetXByH(x * 0.001, y * 0.001, h0) * 1000;
                    double wwS = 1000 * (GetXByH(x * 0.001, y * 0.001, h0) - GetX2ByH(xI * 0.001, yI * 0.001, h0));
                    double llS = Length * 0.5 - 1000 * GetSideXByH(xS * 0.001, yS * 0.001, h0);
                    CalPara(Math.Round(w, 0, MidpointRounding.AwayFromZero), Length, Math.Round(wwS, 0, MidpointRounding.AwayFromZero), Math.Round(llS, 0, MidpointRounding.AwayFromZero), ref a, ref b, ref c);
                    if (m != num)
                        RebarList.Add(new MRORebarRecord(1, m, "", eDB.DB12, 1, eShapeType.MRO, a, b, c));
                    else
                    {
                        a = Length - 50 * 2 - 2 * 12;
                        c = (int)TopLength - 50 * 2 - 2 * 12;
                        RebarList.Add(new MRRebarRecord(1, m, "", eDB.DB12, 1, eShapeType.MR, a, c));
                    }
                }
                CalPara(Width, Length, wwSide, llSide, ref a, ref b, ref c);
                SetRebarDistributeNew(a, c);
                if (SubType == eSubType.F)
                {
                    RebarList.Add(new MORebarRecord(2, 0, "", eDB.DB12, npts, eShapeType.MO, Width - 100 - 24, 76 * 3 + 32));
                    //RebarList.Add(new MORebarRecord(2, 0, "a", eDB.DB16, 3, eShapeType.MO, Width - 100 - 24, 76 * 3 + 32));
                }
                else if (SubType == eSubType.E)
                {
                    RebarList.Add(new MORebarRecord(2, 0, "", eDB.DB12, npts, eShapeType.MO, Width - 100 - 24, 76 * 3 + 32));
                    //RebarList.Add(new MORebarRecord(2, 0, "a", eDB.DB16, 3, eShapeType.MO, Width - 100 - 24, 75 * 3 + 32));
                }
                else
                {
                    //2号筋
                    RebarList.Add(new MORebarRecord(2, 0, "", eDB.DB12, npts, eShapeType.MO, Width - 100 - 24, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));
                    //RebarList.Add(new MORebarRecord(2, 0, "a", eDB.DB16, 3, eShapeType.MO, Width - 100 - 24, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));
                }


                RebarCollection RebarList3a = new RebarCollection();//3a集合
                RebarCollection RebarList3b = new RebarCollection();//3b集合

                for (int m = 1; m <= num; m++)
                {
                    double h0 = 300 * m * 0.001;
                    double w = 2 * GetXByH(x * 0.001, y * 0.001, h0) * 1000;
                    double w2 = 2 * GetX2ByH(xI * 0.001, yI * 0.001, h0) * 1000;
                    double wwS = 1000 * (GetXByH(x * 0.001, y * 0.001, h0) - GetX2ByH(xI * 0.001, yI * 0.001, h0));
                    double llS = Length * 0.5 - 1000 * GetSideXByH(xS * 0.001, yS * 0.001, h0);
                    CalPara(Math.Round(w, 0, MidpointRounding.AwayFromZero), Length, Math.Round(wwS, 0, MidpointRounding.AwayFromZero), Math.Round(llS, 0, MidpointRounding.AwayFromZero), ref a, ref b, ref c);
                    if (m == 10)
                    {
                        llS = 0;
                        wwS = 0;
                        w = TopLength;
                        //SetRebarDistributeIV(w-100 , Length-100+24 , wwS, llS);
                        if (SubType == eSubType.E || SubType == eSubType.F || SubType == eSubType.A)
                        {
                            RebarList3a.Add(new MORebarRecord(3, m, "", eDB.DB12, 3, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));
                        }
                        else
                        {
                            RebarList3a.Add(new MORebarRecord(3, m, "a", eDB.DB12, 1, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));
                            RebarList3b.Add(new MORebarRecord(3, m, "b", eDB.DB12, 2, eShapeType.MO, Length - 100 - 24, three_b[m - 1]));
                        }
                        SetRebarDistributeIIINew(Length - 100 - 24, Width - 100 - 24);
                        if (SubType == eSubType.F || SubType == eSubType.E)
                            RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24, 149 * 3 + 32));
                        else
                            RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));

                    }
                    else
                    {
                        //SetRebarDistributeIII(w, Length, wwS, llS);
                        SetRebarDistributeIIINew(a, c);
                        if (SubType == eSubType.B || SubType == eSubType.C)
                        {

                            RebarList3a.Add(new MORebarRecord(3, m, "a", eDB.DB12, 1, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));
                            RebarList3b.Add(new MORebarRecord(3, m, "b", eDB.DB12, 2, eShapeType.MO, Length - 100 - 24, three_b[m - 1]));
                        }
                        else if (SubType == eSubType.D)
                        {
                            RebarList3a.Add(new MORebarRecord(3, m, "a", eDB.DB12, 1, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));
                            RebarList3b.Add(new MORebarRecord(3, m, "b", eDB.DB12, 2, eShapeType.MO, Length - 100 - 24, three_b[m - 1]));
                        }
                        else if (SubType == eSubType.E || SubType == eSubType.F || SubType == eSubType.A)
                        {
                            RebarList3a.Add(new MORebarRecord(3, m, "", eDB.DB12, 3, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));
                        }
                        if (SubType == eSubType.E || SubType == eSubType.F)
                            RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24 + 2, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 3));
                        else
                            RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24 + 2, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));

                    }
                }

                SetRebarDistribute();
                if (SubType == eSubType.B || SubType == eSubType.A)
                {
                    RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, 168 + 28));
                    //RebarList.Add(new MORebarRecord(3, 0, "a", eDB.DB16, 3 * 2, eShapeType.MO, Length - 100 - 24, 140 + 32));
                }
                else if (SubType == eSubType.C)
                {
                    RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, 140 + 32));
                    //RebarList.Add(new MORebarRecord(3, 0, "a", eDB.DB16, 3 * 2, eShapeType.MO, Length - 100 - 24, 140 + 32));
                }
                else if (SubType == eSubType.D)
                {
                    RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, 120 * 2 + 32));
                    //RebarList.Add(new MORebarRecord(3, 0, "a", eDB.DB16, 3 * 2, eShapeType.MO, Length - 100 - 24, 120 * 2 + 32));
                }
                else if (SubType == eSubType.E)
                {
                    RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, 70 * 3 + 32));
                    //RebarList.Add(new MORebarRecord(3, 0, "a", eDB.DB16, 3 * 2, eShapeType.MO, Length - 100 - 24, 70 * 3 + 32));
                }
                else if (SubType == eSubType.F)
                {
                    RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, 74 * 4 + 32));
                    //RebarList.Add(new MORebarRecord(3, 0, "a", eDB.DB16, 3 * 2, eShapeType.MO, Length - 100 - 24, 74 * 4 + 32));
                }
                else
                {
                    RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, MainWBarDistribute.Distance(1, 2) + 12 * 2 + MainLBarDistribute.Location.Count - 1));
                    //RebarList.Add(new MORebarRecord(3, 0, "a", eDB.DB16, 3 * 2, eShapeType.MO, Length - 100 - 24, MainWBarDistribute.Distance(1, 2) + 12 * 2 + MainLBarDistribute.Location.Count - 1));
                }
                foreach (var item in RebarList3a)
                {
                    RebarList.Add(item);
                }
                foreach (var item in RebarList3b)
                {
                    RebarList.Add(item);
                }
                #endregion
                #region 主筋  
                bool isDiv = false;
                bool isToTop = false;
                //  1-获取承台尺寸
                FootingBase theFooting = MemberFactory.CreatMember(MemberFactory.FromColumnToFooting(ColumnType), SubType);
                int FTHeight = theFooting.Height;
                int FTWidth = theFooting.Width;
                int FTLen = theFooting.Length;
                int db = (int)MainRebarDB;
                //  2-确定分段
                // 起步钢筋距承台底面160；
                double x0 = TopLength * 0.5 - 0.5 * Width + mainDBdia * 0.5 + 50 + 12;
                double x1 = GetXByH(1.5) * 1000 + mainDBdia * 0.5 + 50 + 12;
                double x2 = 0;


                PEArc OuterArc = new PEArc(new Point2D(x0, 0), new Point2D(x1, 1500), new Point2D(x2, 3000 - 50 - mainDBdia * 0.5 - 12));
                //double Lmax = 1200 + OuterArc.Length + (PierHeight - LenUpper) + (FTHeight - 160) + 600 - 3 * mainDBdia;

                int[] value = dicRInfo.Values.ToList()[0];

                int arcR = value[0];
                int arcLength = value[1];
                int arcC = value[2];
                int arcNum = value[3];
                double Lmax = 1500 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) + 600 - 3 * mainDBdia;
                if (MainRebarDB == eDB.DB28)
                    Lmax = 1200 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) + 600 - 3 * mainDBdia;
                int NumMainAll = 0;
                if (Lmax <= 12000)
                {
                    isToTop = true;
                    foreach (var item in dicRInfo.Keys)
                    {
                        value = dicRInfo[item];
                        int arcr = value[0];
                        int arclength = value[1];
                        int arcc = value[2];
                        int arcnum = value[3];
                        int rr = RebarKnowledge.GerRadius(eDB.DB32);
                        int l = (int)((PierHeight - LenUpper) + (FTHeight - 160));
                        int A = 600;        //固定      
                                            //int B = 45;         //固定
                                            //int B = 250;         //固定
                        int F = 1500 - arcc;
                        if (MainRebarDB == eDB.DB28)
                            F = 1200 - arcc;
                        string[] va = item.Split('.');
                        //eDB rebarDB = MainRebarDB;
                        rr = arcr;
                        if (int.Parse(va[0]) == 5)
                        {
                            //rebarDB = eDB.DB28;
                            value = dicRInfo[item];

                            int bb = arclength;
                            int cc = arcc;
                            //int arcnum = value[3];
                            int dd = 1500 - cc;
                            if (rebarDB == eDB.DB28)
                                dd = 1200 - cc;

                            F = 1200 - arcc;
                            if (va.Length == 1)
                                RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                            else if (va.Length == 2)
                                RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                            else if (va.Length == 3)
                                RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));

                        }
                        else
                        {
                            if (va.Length == 1)
                            {
                                RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), 0, "", MainRebarDB, arcnum, eShapeType.MKL, A, l, arclength, arcc, F,rr));
                            }
                            else if (va.Length == 2)
                            {
                                if (int.Parse(va[1]) > 1)
                                    RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MKLM, A, l, arclength, arcc, F, rr));
                                else
                                    RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MKL, A, l, arclength, arcc, F, rr));
                            }
                            else if (va.Length == 3)
                            {
                                if (int.Parse(va[1]) > 1)
                                    RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MKLM, A, l, arclength, arcc, F, rr));
                                else
                                    RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MKL, A, l, arclength, arcc, F, rr));
                            }
                        }
                    }
                }
                else
                {

                    int NumOFout = MainLBarDistribute.Location.Count * 2 + 4;
                    NumMainAll = MainWBarDistribute.Location.Count * 2 + NumOFout;
                    // 判断起步筋定尺7m或9m，判断依据是花瓶主筋的A值应不小于2400
                    double LStartMax = 600 + (PierHeight - LenUpper + (FTHeight - 160) - 3 * mainDBdia);
                    //double L1 = 8483;
                    double L1 = 8494;
                    int len = 9000;
                    double divL = 12000;
                    if (LStartMax > 21800)
                    {
                        len = 12000;
                        //L1 = 11483;
                        L1 = 11494;
                        // 起步筋定尺9m
                        //4.1a为内侧起步筋；

                        RebarList.Add(new MHXRebarRecord(4, 1, "", MainRebarDB, false, NumOFout - 4, eShapeType.MHXe, 12000));

                        RebarList.Add(new MHXRebarRecord(4, 2, "", MainRebarDB, true, NumMainAll - NumOFout, eShapeType.MHX, 12000));
                        //5.1b为外侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 3, "", MainRebarDB, true, 4, eShapeType.MHXe, 12000));

                    }
                    if (LStartMax > 18800)
                    {
                        len = 9000;
                        //L1 = 8483;
                        L1 = 8494;
                        // 起步筋定尺9m
                        //4.1a为内侧起步筋；

                        RebarList.Add(new MHXRebarRecord(4, 1, "", MainRebarDB, false, NumOFout - 4, eShapeType.MHXe, 9000));

                        RebarList.Add(new MHXRebarRecord(4, 2, "", MainRebarDB, true, NumMainAll - NumOFout, eShapeType.MHX, 9000));
                        //5.1b为外侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 3, "", MainRebarDB, true, 4, eShapeType.MHXe, 9000));

                    }
                    if (LStartMax > 16800)
                    {
                        len = 7000;
                        //L1 = 6483;
                        L1 = 6494;
                        // 起步筋定尺9m
                        //4.1a为内侧起步筋；

                        RebarList.Add(new MHXRebarRecord(4, 1, "", MainRebarDB, false, NumOFout - 4, eShapeType.MHXe, 7000));

                        RebarList.Add(new MHXRebarRecord(4, 2, "", MainRebarDB, true, NumMainAll - NumOFout, eShapeType.MHX, 7000));
                        //5.1b为外侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 3, "", MainRebarDB, true, 4, eShapeType.MHXe, 7000));

                    }
                    else if (LStartMax > 12000)
                    {
                        //L1 = 11483;
                        L1 = 11494;
                        len = 12000;
                        // 起步筋定尺9m
                        //4.1a为内侧起步筋；

                        RebarList.Add(new MHXRebarRecord(4, 1, "", MainRebarDB, false, NumOFout - 4, eShapeType.MHXe, 12000));

                        RebarList.Add(new MHXRebarRecord(4, 2, "", MainRebarDB, true, NumMainAll - NumOFout, eShapeType.MHX, 12000));
                        //5.1b为外侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 3, "", MainRebarDB, true, 4, eShapeType.MHXe, 12000));

                    }
                    else if (LStartMax > 9000)
                    {
                        // 起步筋定尺9m
                        //4.1a为内侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 1, "", MainRebarDB, false, NumOFout - 4, eShapeType.MHXe, 9000));

                        RebarList.Add(new MHXRebarRecord(4, 2, "", MainRebarDB, true, NumMainAll - NumOFout, eShapeType.MHX, 9000));
                        //5.1b为外侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 3, "", MainRebarDB, true, 4, eShapeType.MHXe, 9000));
                    }
                    else if (LStartMax > 7000)
                    {
                        // 起步筋定尺7m
                        //4.1a为内侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 1, "", MainRebarDB, false, NumOFout - 4, eShapeType.MHXe, 7000));

                        RebarList.Add(new MHXRebarRecord(4, 2, "", MainRebarDB, true, NumMainAll - NumOFout, eShapeType.MHX, 7000));
                        //5.1b为外侧起步筋；
                        RebarList.Add(new MHXRebarRecord(4, 3, "", MainRebarDB, true, 4, eShapeType.MHX, 7000));
                        len = 7000;
                        L1 = 6483;
                    }
                    else if (LStartMax >= 600 + 2400 + (FTHeight - 160) - 3 * mainDBdia)
                    {
                        // 起步筋搭接位置不合适
                        throw new Exception("起步筋搭接位置不合适，花瓶墩过矮");
                    }
                    int A = 600;        //固定      
                    int C = 45;         //固定
                    C = 250;
                    int D = 2400;       //固定
                    int L = len;       //固定
                    int r = RebarKnowledge.GerRadius(MainRebarDB);
                    int d = 32;
                    if (MainRebarDB == eDB.DB28)
                    {
                        D = 1800;
                        d = 28;
                    }
                    //int B = L - A - C - D + r / 2 + d;
                    int cap = 2400;
                    if (MainRebarDB == eDB.DB28)
                        cap = 1800;
                    int B = L - A - C - D + r / 2 + d;
                    Lmax = 1500 + OuterArc.Length + (PierHeight - LenUpper) + (FTHeight - 160) - L1 + cap * 0.5;
                    if (MainRebarDB == eDB.DB28)
                        Lmax = 1200 + OuterArc.Length + (PierHeight - LenUpper) + (FTHeight - 160) - L1 + cap * 0.5;
                    Lmax = 1500 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) - L1 + 2400;
                    if (MainRebarDB == eDB.DB28)
                        Lmax = 1200 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) - L1 + 2400;
                    if (Lmax <= 12000)
                    {

                        // 分两段
                        double LConst = PierHeight - LenUpper;
                        int aa = (int)Math.Round(LConst + FTHeight - 160 - B - 32, 0, MidpointRounding.AwayFromZero);
                        if (C == 250)
                            aa = (int)Math.Round(LConst + FTHeight - 160 - B - 248, 0, MidpointRounding.AwayFromZero);
                        int bb = arcLength;// (int)Math.Round(arc.Length, 0, MidpointRounding.AwayFromZero);
                        int cc = arcC;// 305;
                        int dd = 1500 - arcC;// 1195;
                        if (MainRebarDB == eDB.DB28)
                            dd = 1200 - arcC;
                        int rr = arcR;// (int)Math.Round(arc.Radius, 0, MidpointRounding.AwayFromZero);
                        foreach (var item in dicRInfo.Keys)
                        {
                            value = dicRInfo[item];
                            int arcr = value[0];
                            bb = value[1];
                            cc = value[2];
                            int arcnum = value[3];
                            dd = 1500 - cc;
                            if (MainRebarDB == eDB.DB28)
                                dd = 1200 - arcC;
                            rr = arcr;
                            string[] va = item.Split('.');
                            //eDB rebarDB = MainRebarDB;
                            if (int.Parse(va[0]) == 5)
                            {
                                //rebarDB = eDB.DB28;
                                dd = 1500 - cc;
                                if (rebarDB == eDB.DB28)
                                    dd = 1200 - cc;
                                //if (va.Length == 1)
                                //    RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                //else if (va.Length == 2)
                                //    RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                //else if (va.Length == 3)
                                //    RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                if (arcr != 0)
                                {
                                    //F = 1200 - arcc;
                                    if (va.Length == 1)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 2)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 3)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                }
                                else
                                {
                                    if (va.Length == 1)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 2)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 3)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                }

                            }
                            else
                            {

                                if (va.Length == 1)
                                    RebarList.Add(new MKRebarRecord(int.Parse(va[0]), 0, "", MainRebarDB, arcnum, eShapeType.MK, aa, bb, cc, dd, rr));
                                else if (va.Length == 2)
                                    RebarList.Add(new MKRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MK, aa, bb, cc, dd, rr));
                                else if (va.Length == 3)
                                    RebarList.Add(new MKRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MK, aa, bb, cc, dd, rr));

                            }
                        }
                    }
                    else if (Lmax <= 24000)
                    {
                        //int cap = 2400;
                        //if (MainRebarDB == eDB.DB28)
                        //    cap = 1800;
                        isDiv = true;
                        // 分三段,中间段12米
                        //int L2 = 12000 - 45 + 32 - 2400;
                        int L2 = 12000 - 250 + 248 - cap;
                        double LConst = PierHeight - LenUpper - (L2 + 248);
                      
                        //int aa = (int)Math.Round(LConst + FTHeight - 160 - B - 32, 0, MidpointRounding.AwayFromZero);
                        int aa = (int)Math.Round(LConst + FTHeight - 160 - B - 248, 0, MidpointRounding.AwayFromZero);
                        int bb = arcLength;// (int)Math.Round(arc.Length, 0, MidpointRounding.AwayFromZero);
                        int cc = arcC;// 305;
                        int dd = 1500 - arcC;// 1195;
                        if (MainRebarDB == eDB.DB28)
                            dd = 1200 - arcC;
                        int rr = arcR;// (int)Math.Round(arc.Radius, 0, MidpointRounding.AwayFromZero);
                        RebarList.Add(new MSZRebarRecord(5, 0, "", MainRebarDB, NumMainAll, eShapeType.MSZ, L2 + cap));
                        foreach (var item in dicRInfo.Keys)
                        {
                            value = dicRInfo[item];
                            int arcr = value[0];
                            bb = value[1];
                            cc = value[2];
                            int arcnum = value[3];
                            dd = 1500 - cc;
                            if (MainRebarDB == eDB.DB28)
                                dd = 1200 - arcC;
                            rr = arcr;
                            string[] va = item.Split('.');
                            //eDB rebarDB = MainRebarDB;
                            if (int.Parse(va[0]) == 5)
                            {
                                //rebarDB = eDB.DB28;
                                dd = 1500 - cc;
                                if (rebarDB == eDB.DB28)
                                    dd = 1200 - cc;
                                //if (va.Length == 1)
                                //    RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR,  bb, cc, dd, rr));
                                //else if (va.Length == 2)
                                //    RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[2]), "", rebarDB, arcnum, eShapeType.MKR,  bb, cc, dd, rr));
                                //else if (va.Length == 3)
                                //    RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[2]), va[2], rebarDB, arcnum, eShapeType.MKR,  bb, cc, dd, rr));
                                if (arcr != 0)
                                {
                                    //F = 1200 - arcc;
                                    if (va.Length == 1)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 2)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 3)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                }
                                else
                                {
                                    if (va.Length == 1)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 2)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                    else if (va.Length == 3)
                                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                                }
                            }
                            else
                            {

                                if (va.Length == 1)
                                    RebarList.Add(new MKRebarRecord(int.Parse(va[0]), 0, "", MainRebarDB, arcnum, eShapeType.MK, aa, bb, cc, dd, rr));
                                else if (va.Length == 2)
                                    RebarList.Add(new MKRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MK, aa, bb, cc, dd, rr));
                                else if (va.Length == 3)
                                    RebarList.Add(new MKRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MK, aa, bb, cc, dd, rr));

                            }
                        }

                    
                    }
                    else if (Lmax <= 36000)
                    {
                        // 分三段
                        throw new NotImplementedException("分四段逻辑没写");

                    }
                }
                #endregion



                #region UBlot数量计算
                if (isToTop)
                {
                    UAN1N2 = 0;
                }
                else
                {
                    if (isDiv)
                        UAN1N2 = NumMainAll * 8;
                    else
                        UAN1N2 = NumMainAll * 4;
                }
                #endregion
            }
        }

        public void SetRebarList110()
        {
            //  1-获取承台尺寸
            FootingBase theFooting = MemberFactory.CreatMember(MemberFactory.FromColumnToFooting(ColumnType), SubType);
            int FTHeight = theFooting.Height;
            int FTWidth = theFooting.Width;
            int FTLen = theFooting.Length;
            #region 0-箍筋
            int npts = GetStirrupNum();

            int a = 0, b = 0, c = 0;
            //1号筋
            CalPara(Width, Length, wwSide, llSide, ref a, ref b, ref c);
            //RebarList.Add(new MRORebarRecord(1, 0, "", eDB.DB12, npts, eShapeType.MRO, a, b, c));
            //RebarList.Add(new MRORebarRecord(1, 0, "a", eDB.DB16, 3, eShapeType.MRO, a, b, c));
            //箍筋变化筋数量
            int num = 7;
            double r1 = 0;
            double r0 = 0;
            double r2 = 0;
            double x = 0;
            double y = 0;
            double xI = 0;
            double yI = 0;
            double xS = 0;
            double yS = 0;
            int diaH = PierHeight + FTHeight - 160;
            CalArcCenter(1750 - Width * 0.5, 0, 0, diaH, OuterRadius, 0, ref r1, ref x, ref y);
            CalArcCenter(1750 - Width * 0.5 + wwSide, 0, 0, diaH, InnerRadius, 0, ref r0, ref xI, ref yI);
            CalArcCenter(450 - llSide, 0, 0, diaH, SideRadius, 0, ref r2, ref xS, ref yS);
            for (int m = 1; m <= num; m++)
            {
                double h0 =( 500 - 160) * 0.001;
                if(m==1)
                    h0 = (500 - 160) * 0.001;
                else if (m <= 3)
                    h0 += 450 * 0.001;
                else
                   h0 += 300 * 0.001;
               
                //double w = 2* GetXByH(h0)*1000;
                double w = 2 * GetXByH(x * 0.001, y * 0.001, h0) * 1000;
                double wwS = 1000 * (GetXByH(x * 0.001, y * 0.001, h0) - GetX2ByH(xI * 0.001, yI * 0.001, h0));
                double llS = Length * 0.5 - 1000 * GetSideXByH(xS * 0.001, yS * 0.001, h0);
                CalPara(Math.Round(w, 0, MidpointRounding.AwayFromZero), Length, Math.Round(wwS, 0, MidpointRounding.AwayFromZero), Math.Round(llS, 0, MidpointRounding.AwayFromZero), ref a, ref b, ref c);
                if (m != num)
                    RebarList.Add(new MRORebarRecord(1, m, "", eDB.DB12, 1, eShapeType.MRO, a, b, c));
                else
                {
                    a = Length - 50 * 2 - 2 * 12;
                    c = (int)TopLength - 50 * 2 - 2 * 12;
                    RebarList.Add(new MRRebarRecord(1, m, "", eDB.DB12, 1, eShapeType.MR, a, c));
                }
            }
            CalPara(Width, Length, wwSide, llSide, ref a, ref b, ref c);
            SetRebarDistributeNew(a, c);

            //2号筋
            //RebarList.Add(new MORebarRecord(2, 0, "", eDB.DB12, npts, eShapeType.MO, Width - 100 - 24, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));



            RebarCollection RebarList3a = new RebarCollection();//3a集合
            RebarCollection RebarList3b = new RebarCollection();//3b集合

            for (int m = 1; m <= num; m++)
            {
                double h0 = (500 - 160) * 0.001;
                if (m == 1)
                    h0 = (500 - 160) * 0.001;
                else if (m <= 3)
                    h0 += 450 * 0.001;
                else
                    h0 += 300 * 0.001;

                double w = 2 * GetXByH(x * 0.001, y * 0.001, h0) * 1000;
                double w2 = 2 * GetX2ByH(xI * 0.001, yI * 0.001, h0) * 1000;
                double wwS = 1000 * (GetXByH(x * 0.001, y * 0.001, h0) - GetX2ByH(xI * 0.001, yI * 0.001, h0));
                double llS = Length * 0.5 - 1000 * GetSideXByH(xS * 0.001, yS * 0.001, h0);
                CalPara(Math.Round(w, 0, MidpointRounding.AwayFromZero), Length, Math.Round(wwS, 0, MidpointRounding.AwayFromZero), Math.Round(llS, 0, MidpointRounding.AwayFromZero), ref a, ref b, ref c);
                if (m == num)
                {
                    llS = 0;
                    wwS = 0;
                    w = TopLength;

                    RebarList3a.Add(new MORebarRecord(3, m, "", eDB.DB12, 3, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));

                    SetRebarDistributeIIINew(Length - 100 - 24, Width - 100 - 24);

                    RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));

                }
                else
                {
                    //SetRebarDistributeIII(w, Length, wwS, llS);
                    SetRebarDistributeIIINew(a, c);

                    RebarList3a.Add(new MORebarRecord(3, m, "", eDB.DB12, 3, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));

                    RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24 + 2, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));

                }
            }

            SetRebarDistribute();

            //RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, 168 + 28));


            foreach (var item in RebarList3a)
            {
                RebarList.Add(item);
            }
            foreach (var item in RebarList3b)
            {
                RebarList.Add(item);
            }
            #endregion
            #region 主筋  
            bool isDiv = false;
            bool isToTop = false;
            ////  1-获取承台尺寸
            //FootingBase theFooting = MemberFactory.CreatMember(MemberFactory.FromColumnToFooting(ColumnType), SubType);
            //int FTHeight = theFooting.Height;
            //int FTWidth = theFooting.Width;
            //int FTLen = theFooting.Length;
            int db = (int)MainRebarDB;
            //  2-确定分段
            // 起步钢筋距承台底面160；
            double x0 = TopLength * 0.5 - 0.5 * Width + mainDBdia * 0.5 + 50 + 12;
            double x1 = GetXByH(1.5) * 1000 + mainDBdia * 0.5 + 50 + 12;
            double x2 = 0;


            PEArc OuterArc = new PEArc(new Point2D(x0, 0), new Point2D(x1, 1500), new Point2D(x2, 3000 - 50 - mainDBdia * 0.5 - 12));

            int[] value = dicRInfo.Values.ToList()[0];

            int arcR = value[0];
            int arcLength = value[1];
            int arcC = value[2];
            int arcNum = value[3];
            double Lmax = 1500 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) + 600 - 3 * mainDBdia;
            if (MainRebarDB == eDB.DB28)
                Lmax = 1200 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) + 600 - 3 * mainDBdia;

            isToTop = true;
            foreach (var item in dicRInfo.Keys)
            {
                value = dicRInfo[item];
                int arcr = value[0];
                int arclength = value[1];
                int arcc = value[2];
                int arcnum = value[3];
                int rr = arcr;

                int A = 600;        //固定      
                int D = 1500 - arcc;
                int B = arclength;
                int C = arcc;
                if (MainRebarDB == eDB.DB28)
                    D = 1200 - arcc;
                string[] va = item.Split('.');
               
                if (int.Parse(va[0]) == 5)
                {
                    //rebarDB = eDB.DB28;
                    value = dicRInfo[item];

                    int bb = arclength;
                    int cc = arcc;
                    //int arcnum = value[3];
                    int dd = 1500 - cc;
                    if (rebarDB == eDB.DB28)
                        dd = 1200 - cc;

                    if (va.Length == 1)
                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                    else if (va.Length == 2)
                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                    else if (va.Length == 3)
                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));

                }
                else if (int.Parse(va[0]) == 6)
                {
                    //rebarDB = eDB.DB28;
                    value = dicRInfo[item];

                    int bb = arclength;
                    int cc = arcc;
                    //int arcnum = value[3];
                    int dd = 1500 - cc;
                    if (rebarDB == eDB.DB28)
                        dd = 1200 - cc;

                    if (va.Length == 1)
                        RebarList.Add(new MKRMRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR2, bb, cc, dd, rr));
                    else if (va.Length == 2)
                        RebarList.Add(new MKRMRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR2, bb, cc, dd, rr));
                    else if (va.Length == 3)
                        RebarList.Add(new MKRMRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR2, bb, cc, dd, rr));

                }
                else if (int.Parse(va[0]) == 7)
                {
                    //rebarDB = eDB.DB28;
                    value = dicRInfo[item];

                    int bb = arclength;
                    int cc = arcc;
                    //int arcnum = value[3];
                    int dd = 1500 - cc;
                    if (rebarDB == eDB.DB28)
                        dd = 1200 - cc;

                 
                    if (va.Length == 1)
                        RebarList.Add(new MKABRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKAB, bb, cc,  rr));
                    else if (va.Length == 2)
                        RebarList.Add(new MKABRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKAB, bb, cc,  rr));
                    else if (va.Length == 3)
                        RebarList.Add(new MKABRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKAB, bb, cc,  rr));

                }
                else
                {
                    if (va.Length == 1)
                    {
                        RebarList.Add(new MKADRebarRecord(int.Parse(va[0]), 0, "", MainRebarDB, arcnum, eShapeType.MKL, A,  arclength, arcc, D, rr));
                    }
                    else if (va.Length == 2)
                    {
                        if (int.Parse(va[1]) > 1)
                            RebarList.Add(new MKADRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MKLM, A, arclength, arcc, D, rr));
                        else
                            RebarList.Add(new MKADRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MKL, A,  arclength, arcc, D, rr));
                    }
                    else if (va.Length == 3)
                    {
                        if (int.Parse(va[1]) == 1)
                        {
                            if(D!=0)
                            RebarList.Add(new MKADRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MKAD1, A, arclength, arcc, D, rr));
                            else
                                RebarList.Add(new MKRMRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR1, A, arclength, arcc, rr));
                        }
                        else if (int.Parse(va[1]) == 2)
                            RebarList.Add(new MKADRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MKAD2, A, arclength, arcc, D, rr));
                        else
                            RebarList.Add(new MKADRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MKL, A,  arclength, arcc, D, rr));
                    }
                }
            }


            #endregion



            #region UBlot数量计算

            UAN1N2 = 0;

            #endregion
        }

        public void SetRebarList258()
        {
            //  1-获取承台尺寸
            FootingBase theFooting = MemberFactory.CreatMember(MemberFactory.FromColumnToFooting(ColumnType), SubType);
            int FTHeight = theFooting.Height;
            int FTWidth = theFooting.Width;
            int FTLen = theFooting.Length;
            #region 0-箍筋
            int npts = 2;

            int a = 0, b = 0, c = 0;
            //1号筋
            CalPara(Width, Length, wwSide, llSide, ref a, ref b, ref c);
            RebarList.Add(new MRORebarRecord(1, 0, "", eDB.DB12, npts, eShapeType.MRO, a, b, c));
            //RebarList.Add(new MRORebarRecord(1, 0, "a", eDB.DB16, 3, eShapeType.MRO, a, b, c));
            //箍筋变化筋数量
            int num = 10;
            double r1 = 0;
            double r0 = 0;
            double r2 = 0;
            double x = 0;
            double y = 0;
            double xI = 0;
            double yI = 0;
            double xS = 0;
            double yS = 0;
            CalArcCenter(1750 - Width * 0.5, 0, 0, 3000, OuterRadius, 0, ref r1, ref x, ref y);
            CalArcCenter(1750 - Width * 0.5 + wwSide, 0, 0, 3000, InnerRadius, 0, ref r0, ref xI, ref yI);
            CalArcCenter(450 - llSide, 0, 0, 3000, SideRadius, 0, ref r2, ref xS, ref yS);
          
            for (int m = 1; m <= num; m++)
            {

                double h0 = 300 * m * 0.001;
                if (m >= 8)
                    h0 = 300 * m * 0.001 - 3 * 0.001;
                double w = 2 * GetXByH(x * 0.001, y * 0.001, h0) * 1000;
                double wwS = 1000 * (GetXByH(x * 0.001, y * 0.001, h0) - GetX2ByH(xI * 0.001, yI * 0.001, h0));
                double llS = Length * 0.5 - 1000 * GetSideXByH(xS * 0.001, yS * 0.001, h0);
                CalPara(Math.Round(w, 0, MidpointRounding.AwayFromZero), Length, Math.Round(wwS, 0, MidpointRounding.AwayFromZero), Math.Round(llS, 0, MidpointRounding.AwayFromZero), ref a, ref b, ref c);
                if (m != num)
                    RebarList.Add(new MRORebarRecord(1, m, "", eDB.DB12, 1, eShapeType.MRO, a, b, c));
                else
                {
                    a = Length - 50 * 2 - 2 * 12;
                    c = (int)TopLength - 50 * 2 - 2 * 12;
                    RebarList.Add(new MRRebarRecord(1, m, "", eDB.DB12, 1, eShapeType.MR, a, c));
                }
            }
            CalPara(Width, Length, wwSide, llSide, ref a, ref b, ref c);
            SetRebarDistributeNew(a, c);

            //2号筋
            RebarList.Add(new MORebarRecord(2, 0, "", eDB.DB12, npts, eShapeType.MO, Width - 100 - 24, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));


            RebarCollection RebarList3a = new RebarCollection();//3a集合
            RebarCollection RebarList3b = new RebarCollection();//3b集合

            for (int m = 1; m <= num; m++)
            {
                double h0 = 300 * m * 0.001;
                double w = 2 * GetXByH(x * 0.001, y * 0.001, h0) * 1000;
                double w2 = 2 * GetX2ByH(xI * 0.001, yI * 0.001, h0) * 1000;
                double wwS = 1000 * (GetXByH(x * 0.001, y * 0.001, h0) - GetX2ByH(xI * 0.001, yI * 0.001, h0));
                double llS = Length * 0.5 - 1000 * GetSideXByH(xS * 0.001, yS * 0.001, h0);
                CalPara(Math.Round(w, 0, MidpointRounding.AwayFromZero), Length, Math.Round(wwS, 0, MidpointRounding.AwayFromZero), Math.Round(llS, 0, MidpointRounding.AwayFromZero), ref a, ref b, ref c);
                if (m == num)
                {
                    llS = 0;
                    wwS = 0;
                    w = TopLength;

                    RebarList3a.Add(new MORebarRecord(3, m, "", eDB.DB12, 3, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));

                    SetRebarDistributeIIINew(Length - 100 - 24, Width - 100 - 24);

                    RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));

                }
                else
                {
                    SetRebarDistributeIIINew(a, c);

                    RebarList3a.Add(new MORebarRecord(3, m, "", eDB.DB12, 3, eShapeType.MO, Length - 100 - 24, three_a[m - 1]));

                    RebarList.Add(new MORebarRecord(2, m, "", eDB.DB12, 1, eShapeType.MO, (int)w - 100 - 24 + 2, (int)MainLBarDistribute.Location[1] * -2 + mainDBdia + 1));

                }
            }

            SetRebarDistribute();

            RebarList.Add(new MORebarRecord(3, 0, "", eDB.DB12, npts * 2, eShapeType.MO, Length - 100 - 24, 168 + 28));

            foreach (var item in RebarList3a)
            {
                RebarList.Add(item);
            }
            foreach (var item in RebarList3b)
            {
                RebarList.Add(item);
            }
            #endregion
            #region 主筋  
            bool isDiv = false;
            bool isToTop = false;

            int db = (int)MainRebarDB;
            //  2-确定分段
            // 起步钢筋距承台底面160；
            double x0 = TopLength * 0.5 - 0.5 * Width + mainDBdia * 0.5 + 50 + 12;
            double x1 = GetXByH(1.5) * 1000 + mainDBdia * 0.5 + 50 + 12;
            double x2 = 0;


            PEArc OuterArc = new PEArc(new Point2D(x0, 0), new Point2D(x1, 1500), new Point2D(x2, 3000 - 50 - mainDBdia * 0.5 - 12));

            int[] value = dicRInfo.Values.ToList()[0];

            int arcR = value[0];
            int arcLength = value[1];
            int arcC = value[2];
            int arcNum = value[3];
            double Lmax = 1500 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) + 600 - 3 * mainDBdia;
            if (MainRebarDB == eDB.DB28)
                Lmax = 1200 + arcLength + (PierHeight - LenUpper) + (FTHeight - 160) + 600 - 3 * mainDBdia;
            int NumMainAll = 0;

            isToTop = true;
            foreach (var item in dicRInfo.Keys)
            {
                value = dicRInfo[item];
                int arcr = value[0];
                int arclength = value[1];
                int arcc = value[2];
                int arcnum = value[3];
                int rr = RebarKnowledge.GerRadius(eDB.DB32);
                int l = (int)((PierHeight - LenUpper) + (FTHeight - 160));
                int A = 600;        //固定      

                int F = 1500 - arcc;
                if (MainRebarDB == eDB.DB28)
                    F = 1200 - arcc;
                string[] va = item.Split('.');
                //eDB rebarDB = MainRebarDB;
                rr = arcr;
                if (int.Parse(va[0]) == 5)
                {
                    //rebarDB = eDB.DB28;
                    value = dicRInfo[item];

                    int bb = arclength;
                    int cc = arcc;
                    //int arcnum = value[3];
                    int dd = 1500 - cc;
                    if (rebarDB == eDB.DB28)
                        dd = 1200 - cc;

                    F = 1200 - arcc;
                    if (va.Length == 1)
                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), 0, "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                    else if (va.Length == 2)
                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));
                    else if (va.Length == 3)
                        RebarList.Add(new MKRRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], rebarDB, arcnum, eShapeType.MKR, bb, cc, dd, rr));

                }
                else
                {
                    if (va.Length == 1)
                    {
                        RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), 0, "", MainRebarDB, arcnum, eShapeType.MKL, A, l, arclength, arcc, F, rr));
                    }
                    else if (va.Length == 2)
                    {
                        if (int.Parse(va[1]) > 1)
                            RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MKLM, A, l, arclength, arcc, F, rr));
                        else
                            RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), "", MainRebarDB, arcnum, eShapeType.MKL, A, l, arclength, arcc, F, rr));
                    }
                    else if (va.Length == 3)
                    {
                        if (int.Parse(va[1]) > 1)
                            RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MKLM, A, l, arclength, arcc, F, rr));
                        else
                            RebarList.Add(new MKLRebarRecord(int.Parse(va[0]), int.Parse(va[1]), va[2], MainRebarDB, arcnum, eShapeType.MKL, A, l, arclength, arcc, F, rr));
                    }
                }
            }


            #endregion



            #region UBlot数量计算

            UAN1N2 = 0;
            #endregion
        }
    }

}
